import { http } from '../../network/index'
import axios from 'axios'

const user = {
    state: {
        userlist: [],//用户列表
        userlength: 0
    },
    mutations: {
        userlist(state, item) {
            state.userlist = item
        },
        userlength(state, item) {
            state.userlength = item
        },
        fenye(state, item) {
            state.userlist = item
        },

    },
    actions: {
        GETuserlist(context) {
            http.users({
                params: {
                    pagenum: 1,
                    pagesize: 5
                }
            }).then(res => {
                // console.log(res.data.data.users);
                context.commit('userlist', res.data.data.users)
                context.commit('userlength', res.data.data.total)
            })
        },
        FENYE(context, val) {
            http.users({
                params: {
                    pagenum: val,
                    pagesize: 5
                }
            }).then(res => {
                context.commit('fenye', res.data.data.users)
            })
        },
        ADDuser(context, obj) {
            // console.log(obj.username);
            http.addusers({

                username: obj.username,
                password: obj.pass,
                email: obj.email,
                mobile: obj.mobile

            }).then(res => {
                
            })
        }

    },
    modules: {}
}

export default user